<?php
namespace App\Common\Lib\Hyperf;

use App\Common as com;
use Hyperf\Snowflake\IdGeneratorInterface;

class Container extends com\Lib\LibBase {

	/**
	 * 获取redis
	 * @return \Hyperf\Redis\Redis
	 */
	public static function getRedis(  ):\Hyperf\Redis\Redis {
		return self::getContainer()->get( \Hyperf\Redis\Redis::class );
	}

	/**
	 * 获取缓存
	 * @return \Psr\SimpleCache\CacheInterface
	 */
	public static function getCache(  ):\Psr\SimpleCache\CacheInterface {
		return self::getContainer()->get( \Psr\SimpleCache\CacheInterface::class );
	}

	/**
	 * 获取雪花id生成器
	 * @return IdGeneratorInterface
	 */
	public static function getSnowflakeIdGenerator(  ):IdGeneratorInterface {
		return self::getContainer()->get( IdGeneratorInterface::class );
	}

	/**
	 * 获取容器
	 * @return \Psr\Container\ContainerInterface
	 */
	public static function getContainer(  ):\Psr\Container\ContainerInterface {
		return \Hyperf\Utils\ApplicationContext::getContainer();
	}
}
